package org.droid.campusorder.adapter;

import java.util.HashMap;
import java.util.List;

import org.droid.R;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ShopCatAdapter extends BaseAdapter  {
	private List<HashMap<String,String>> list;
	private Context context;
	private LayoutInflater inflater;
	private Hodle hodle;
	
	public ShopCatAdapter(Context context) {
		this.context = context;
		inflater = LayoutInflater.from(context);
	}
	
	public void setList(List<HashMap<String, String>> list) {
		this.list = list;
	}


	@Override
	public int getCount() {
		return list == null?0:list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView == null){
			convertView = inflater.inflate(R.layout.shop_cat, null);
			hodle = new Hodle();
			hodle.text = (TextView) convertView.findViewById(R.id.shop_cat_tv);
			convertView.setTag(hodle);
		}else{
			hodle = (Hodle) convertView.getTag();
		}
		hodle.text.setText(list.get(position).get("cat"));
		
		return convertView;
	}

	class Hodle{
		TextView text;
	}
	
}
